﻿Public Class Form1
    Private mw_sec As Double = 0
    Private a_rpm(30) As String
    Private max_rpm As Integer = 3000
    Private count_rpm As Integer

    Private Sub Form1_MouseWheel(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseWheel

        mw_sec = mw_sec + e.Delta
    End Sub

    Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click

    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        Label1.Text = mw_sec

        Dim a_rpm_old(30) As String
        Dim ate As Integer = a_rpm.Length
        Dim a_count As Integer
        Label4.Text = ate

        For Each rpm_sec In a_rpm
            'a_rpm_old(a_count)=
        Next

        mw_sec = 0
    End Sub
    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' Dock the PictureBox to the form and set its background to white.
        'pictureBox1.Dock = DockStyle.Fill
        pictureBox1.BackColor = Color.White
        ' Connect the Paint event of the PictureBox to the event handler method.
        AddHandler pictureBox1.Paint, AddressOf Me.pictureBox1_Paint
        ' Add the PictureBox control to the Form.
        Me.Controls.Add(PictureBox1)


        'init array for rpm
        Dim i As Integer
        For i = 0 To a_rpm.Length - 1
            a_rpm(i) = "0"
        Next i

    End Sub 'Form1_Load
    Private Sub pictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs)
        ' Create a local version of the graphics object for the PictureBox.
        Dim g As Graphics = e.Graphics

        Dim xmax As Integer = PictureBox1.Size.Width
        Dim ymax As Integer = PictureBox1.Size.Height

        ' g.DrawLine(Pens.Black, (xmax - 1), (ymax - 1), (xmax - 10), (ymax - 230))
     

        'g.DrawLine(Pens.Black, (1), (ymax - 1), (2), (ymax - 1))

        Dim astep As Integer = 0
        Dim rpm_sec As Integer = 1
        Dim ratio_astep As Integer = 0
        Dim old_ratio_astep As Integer = 0
        Dim yplot As Integer

        'calculate ratios
        Dim xratio = xmax / (a_rpm.Length - 1) 'in this case 30 seconds
        Dim yratio = ymax / max_rpm

        For Each rpm_sec In a_rpm
            yplot = a_rpm(astep) * yratio
            g.DrawLine(Pens.Black, (ratio_astep), (ymax - yplot), (ratio_astep + 1), (ymax - yplot))
            astep = astep + 1
            ratio_astep = astep * xratio

        Next


    End Sub 'pictureBox1_Paint
End Class
